package com.thor.palmmall.rest.order.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.order.AProductLine;
import com.thor.palmmall.spi.order.SProductLine;

public class AProductLineConverter implements Converter<List<SProductLine>,List<AProductLine>>{
	public static AProductLineConverter getInstance() {
		if (instance == null)
			instance = new AProductLineConverter();
		return instance;
	}

	private static AProductLineConverter instance;

	@Override
	public List<AProductLine> convert(List<SProductLine> sourceList) {
		if(sourceList == null || sourceList.size()==0){
			return null;
		}
		List<AProductLine> list = new ArrayList<AProductLine>();
		for (SProductLine source : sourceList) {
			AProductLine target = new AProductLine();
			target.setUuid(source.getUuid());
			target.setPdtUuid(source.getPdtUuid());
			target.setCode(source.getCode());
			target.setName(source.getName());
			target.setSpecification(source.getSpecification());
			target.setModel(source.getModel());
			target.setQty(source.getQty());
			target.setPrice(source.getPrice());
			target.setOriginalPrice(source.getOriginalPrice());
			target.setStdTotal(source.getStdTotal());
			target.setRemark(source.getRemark());
			target.setCategory(UCN.newInstance(source.getCategory()));
			list.add(target);
		}
		return list;
	}
}

